<%@ page language="java" import="java.util.*,com.commons.*" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML">
<html>
<head>
<title>订单管理</title>
<base href="<%=basePath%>">
<script type="text/javascript"
	src="/js/jquery-1.8.0.js"></script>
<script type="text/javascript"
	src="/js/My97DatePicker/WdatePicker.js"></script>

<script type="text/javascript">
	$(function() {
		$("table tr").mouseover(function() {
			$(this).css("background", "#D3EAEF");
			$(this).siblings().css("background", "white");
		});
	});
</script>
<link rel="stylesheet" type="text/css"
	href="${pageContext.request.contextPath}/css/maintable.css"></link>
<style>
.div_tools {
	width: 99.5%;
	height: 28px;
	background: #D3EAEF;
	margin: 0px auto;
	margin-top: 5px;
	margin-bottom: 5px;
	font-size: 12px;
	position: relative;
}

.div_tools select {
	height: 22px;
	font-size: 12px;
	margin-top: 3px;
}

#btnsubmit {
	width: 40px;
	height: 20px;
	font-size: 12px;
}
</style>

</head>

<body>

	<div class="div_title">
		<div class="div_titlename">
			<img src="images/san_jiao.gif"><span>订单列表</span>
		</div>
	</div>
	<form
		action="OrderServlet.do?flag=manage"
		method="post" name="form1">
		<div class="div_tools">
			&nbsp; &nbsp; &nbsp; 订单号: <input type="text" name="orderNo"
				value="${param.orderNo }"></input> 下单日期从: <input type="text"
				name="beginDate" onclick="WdatePicker()" value="${param.beginDate}" />
			到: <input type="text" name="endDate" onclick="WdatePicker()"
				value="${param.endDate}" /> 订单状态:

			<%
 				request.setAttribute("orderStateList",Enums.EnumOrderState.values());
			 %>
			
			<select name="orderState" id="orderState">
				<option value="全部">全部</option>
				<c:forEach var="state" items="${orderStateList}">
					<option value="${state.value}">${state}</option>
				</c:forEach>
			</select> 
			
			<input id="btnsubmit" type="submit" value="查询" />
		</div>

		<input type="hidden" name="flag" value="delAdmins" />
		<table class="main_table">
			<tr>
				<th>订单号</th>
				<th>付款方式</th>
				<th>定单金额</th>
				<th>订单状态</th>
				<th>邮寄方式</th>
				<th>生成日期</th>
				<th>发货地址</th>
				<th>操作</th>
			</tr>
			<c:forEach var="order" items="${orderList}">
				<tr>
					<td>${order.orderNo}</td>
					<td>${order.payMethod}</td>
					<td>${order.amount}</td>
					<td>${order.orderState }</td>
					<td>${order.postMethod }</td>
					<td>${order.orderDate }</td>
					<td>${order.address }</td>
					<td>
						<c:set var="weifukuan" value="<%=Enums.EnumOrderState.未付款%>"></c:set> 
						<c:set var="yifukuan" value="<%=Enums.EnumOrderState.已支付%>"> </c:set> 
						<c:set var="yifahuo" value="<%=Enums.EnumOrderState.已发货%>"></c:set> 
						
						<a href="OrderServlet.do?flag=orderview&id=${order.id}">查看</a> | 
					    <c:if test="${order.orderState == yifukuan}">
							<a onclick="return confirm('确定要进行发货操作吗')" href="OrderServlet.do?pageIndex=${page.pageIndex}&flag=sendgoods&id=${order.id}">发货</a> |   
				 		</c:if> 
				 		<c:if test="${order.orderState eq weifukuan}">
							<a onclick="return confirm('确定要删除该订单吗?')"  
								href="OrderServlet.do?flag=del&id=${order.id}">刪除</a> |  
				 		</c:if> 
					</td>
				</tr>
			</c:forEach>
		</table>



		<div class="div_page" >
			  <div class="div_page_left">    共有 <label>${page.rowCount}</label> 条记录，当前第 <label>${page.pageIndex}</label> 页，共 <label>${page.pageCount}</label> 页	</div>		
			  <div class="div_page_right" > 	 
			  			 <a href="OrderServlet.do?flag=manage&pageIndex=1" >首页</a>
		  	 			 <a href="OrderServlet.do?flag=manage&pageIndex=${page.pageIndex-1 }">上一页</a>
			  			 <a href="OrderServlet.do?flag=manage&pageIndex=${page.pageIndex+1 }">下一页 </a>
		  	 		   	 <a href="OrderServlet.do?flag=manage&pageIndex=${page.pageCount}">尾页</a>
			  <button>转到</button>
			  <input type="text" name="pageIndex" id="pageIndex" value="${page.pageIndex}"  type="number"/> 页
			</div>
				
		</div>

	</form>
	<script type="text/javascript">
		var msg = '${msg}';
		if (msg != '') {
			alert(msg);
		}
		$(function(){
			var selectedstate='${param.orderState}'
			if(selectedstate!=''){
				$("option").each(function(){
	     			if(this.value==selectedstate){
	     				this.selected=true;
	     			}
	     		})
			}
		})
	</script>
</body>
</html>
